package com.tensai.utils;

import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * 基础工具
 *
 * @author Tensai
 */
public class BasicUtil {

	public static void sleep(int time) {
		try {
			TimeUnit.SECONDS.sleep(time);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
	}

	/**
	 * 获取Class类的方法
	 *
	 * @param clazz 类对象
	 * @return 方法集合
	 * @param <T> 类
	 */
	public static <T> Set<String> getMethodSet(Class<T> clazz) {
		Set<String> set = new HashSet<>();
		for (Method method : clazz.getMethods()) {
			set.add(method.getName());
		}
		return set;
	}

	public static <T> Set<String> getMethodString(Class<T> clazz){
		Set<String> set = new HashSet<>();
		for (Method method : clazz.getMethods()) {
			set.add(method.getName() + "," + method.getReturnType().getSimpleName());
		}
		return set;
	}
}
